//
// Created by Toosan on 2022/4/25.
//

#include "iostream"

using namespace std;

class Person {
public:
    int age;

    Person(int age, char *name) {
        this->name = name;
        this->age = age;
    }

    int getAge() const {
        return this->age;
    }

    char *getName() {
        return this->name;
    }

private:
    char *name;
};

/**
 * 默认是私有继承，私有继承会导致子类无法使用父类的公开成员变量
 * 需要手动加上 public   java只有公开继承，不搞这些骚操作
 * C ++  支持多继承
 */
class Student : public Person {
private:
    char *student_number;
public:
    Student(char *number, int age, char *name) : Person(age, name), student_number(number) {
    }

    void printStudent() {
        cout << "number = " << this->student_number << ", name = "
             << getName() << ", age = " << getAge() << endl;
    }
};

/**
 * C++ 继承
 * @return
 */
int main() {
    Student student("20154206073", 24, "Toosan");
    cout << student.age << endl;
    student.printStudent();
    return 0;
}